package com.wn.www.generator;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

public class SystemGenerator {
    public static void main(String[] args) {
        //修改路径
        String path = "D:\\cch\\IDEAproject\\car-life\\car-life-service\\lottery";

        String pathCode = path + "\\src\\main\\java";
        String pathMapper = path + "\\src\\main\\resources\\mapper";

        // 连接数据库
        FastAutoGenerator.create(
                        "jdbc:mysql://localhost:3306/car_life?serverTimezone=UTC",
                        "root", "123456")

                .globalConfig(builder -> {
                    builder.author("mane") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            //.dateType(DateType.ONLY_DATE)
                            .disableOpenDir()
                            .outputDir(pathCode); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.woniu.lottery") // 设置父包名
                            .moduleName(null) // 设置父包模块名
                            .pathInfo(Collections.singletonMap(
                                    OutputFile.xml, pathMapper)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().enableLombok();
                    builder.controllerBuilder().enableHyphenStyle().enableRestStyle();
                    builder.addInclude("lottery_activity","lottery_prize","lottery_record"); // 设置需要生成的表名
//                            .addTablePrefix(""); // 设置过滤表前缀
                })
                .execute();
    }
}
